From 44e41ca0bcd96588252be3143964df602cc3e5d0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 26 Nov 2010 14:17:01 +0000 Subject: [PATCH] xenpaging: allow only one xenpaging binary per guest Make sure only one xenpaging binary is active per domain. Print info when the host lacks the required features for xenpaging. Signed-off-by: Olaf Hering Already-Acked-by: Patrick Colp Already-Acked-by: Keir Fraser --- tools/xenpaging/xenpaging.c | 12 +++++++++++- xen/arch/x86/mm/mem_event.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 64e265c405..d33dde1c87 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -123,7 +123,17 @@ xenpaging_t *xenpaging_init(xc_interface **xch_r, domid_t domain_id) paging->mem_event.ring_page); if ( rc != 0 ) { - ERROR("Error initialising shared page"); + switch ( errno ) { + case EBUSY: + ERROR("xenpaging is (or was) active on this domain"); + break; + case ENODEV: + ERROR("EPT not supported for this guest"); + break; + default: + perror("Error initialising shared page"); + break; + } goto err; } diff --git a/xen/arch/x86/mm/mem_event.c b/xen/arch/x86/mm/mem_event.c index 5bf211d0a8..5187a72a6c 100644 --- a/xen/arch/x86/mm/mem_event.c +++ b/xen/arch/x86/mm/mem_event.c @@ -214,6 +214,13 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec, mfn_t ring_mfn; mfn_t shared_mfn; + /* Only one xenpaging at a time. If xenpaging crashed, + * the cache is in an undefined state and so is the guest + */ + rc = -EBUSY; + if ( d->mem_event.ring_page ) + break; + /* Currently only EPT is supported */ rc = -ENODEV; if ( !(hap_enabled(d) && -- 2.30.2